/*
 * Copyright 2009 Bushel Project Members (http://bushel.googlecode.com/)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.ivy.plugins.resolver;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.Collection;
import java.util.Date;
import java.util.Map;

import org.apache.ivy.core.cache.ArtifactOrigin;
import org.apache.ivy.core.cache.RepositoryCacheManager;
import org.apache.ivy.core.event.EventManager;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.DownloadReport;
import org.apache.ivy.core.resolve.DownloadOptions;
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
import org.apache.ivy.core.search.ModuleEntry;
import org.apache.ivy.core.search.OrganisationEntry;
import org.apache.ivy.core.search.RevisionEntry;
import org.apache.ivy.plugins.latest.LatestStrategy;
import org.apache.ivy.plugins.namespace.Namespace;
import org.apache.ivy.plugins.repository.Resource;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;

/**
 * Hack: wrapper of BasicResolver to make {@link #findArtifactRef(Artifact, Date)} public
 */
public class BasicResolverWrapper extends BasicResolver {

    private final BasicResolver delegate;

    public BasicResolverWrapper(BasicResolver delegate) {
        this.delegate = delegate;
    }

    @Override
    public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
        return delegate.findArtifactRef(artifact, date);
    }

    @Override
    protected Collection findNames(Map tokenValues, String token) {
        return delegate.findNames(tokenValues, token);
    }

    @Override
    protected long get(Resource resource, File dest) throws IOException {
        return delegate.get(resource, dest);
    }

    @Override
    protected Resource getResource(String source) throws IOException {
        return delegate.getResource(source);
    }

    @Override
    public void abortPublishTransaction() throws IOException {
        delegate.abortPublishTransaction();
    }

    @Override
    public void beginPublishTransaction(ModuleRevisionId module, boolean overwrite) throws IOException {
        delegate.beginPublishTransaction(module, overwrite);
    }

    @Override
    public void commitPublishTransaction() throws IOException {
        delegate.commitPublishTransaction();
    }

    @Override
    public DownloadReport download(Artifact[] artifacts, DownloadOptions options) {
        return delegate.download(artifacts, options);
    }

    @Override
    public ArtifactDownloadReport download(ArtifactOrigin origin, DownloadOptions options) {
        return delegate.download(origin, options);
    }

    @Override
    public void dumpSettings() {
        delegate.dumpSettings();
    }

    @Override
    public boolean equals(Object obj) {
        return delegate.equals(obj);
    }

    @Override
    public boolean exists(Artifact artifact) {
        return delegate.exists(artifact);
    }

    public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
        return delegate.findIvyFileRef(dd, data);
    }

    @Override
    public String[] getChecksumAlgorithms() {
        return delegate.getChecksumAlgorithms();
    }

    @Override
    public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {
        return delegate.getDependency(dd, data);
    }

    @Override
    public EventManager getEventManager() {
        return delegate.getEventManager();
    }

    @Override
    public String getLatest() {
        return delegate.getLatest();
    }

    @Override
    public LatestStrategy getLatestStrategy() {
        return delegate.getLatestStrategy();
    }

    @Override
    public String getName() {
        return delegate.getName();
    }

    @Override
    public Namespace getNamespace() {
        return delegate.getNamespace();
    }

    @Override
    public RepositoryCacheManager getRepositoryCacheManager() {
        return delegate.getRepositoryCacheManager();
    }

    @Override
    public ResolverSettings getSettings() {
        return delegate.getSettings();
    }

    @Override
    public String getTypeName() {
        return delegate.getTypeName();
    }

    @Override
    public String getWorkspaceName() {
        return delegate.getWorkspaceName();
    }

    @Override
    public int hashCode() {
        return delegate.hashCode();
    }

    @Override
    public String hidePassword(String name) {
        return delegate.hidePassword(name);
    }

    @Override
    public boolean isAllownomd() {
        return delegate.isAllownomd();
    }

    @Override
    public boolean isCheckconsistency() {
        return delegate.isCheckconsistency();
    }

    @Override
    public boolean isEnvDependent() {
        return delegate.isEnvDependent();
    }

    @Override
    public boolean isForce() {
        return delegate.isForce();
    }

    @Override
    public boolean isValidate() {
        return delegate.isValidate();
    }

    @Override
    public ModuleEntry[] listModules(OrganisationEntry org) {
        return delegate.listModules(org);
    }

    @Override
    public OrganisationEntry[] listOrganisations() {
        return delegate.listOrganisations();
    }

    @Override
    public RevisionEntry[] listRevisions(ModuleEntry mod) {
        return delegate.listRevisions(mod);
    }

    @Override
    public String[] listTokenValues(String token, Map otherTokenValues) {
        return delegate.listTokenValues(token, otherTokenValues);
    }

    @Override
    public Map[] listTokenValues(String[] tokens, Map criteria) {
        return delegate.listTokenValues(tokens, criteria);
    }

    @Override
    public ArtifactOrigin locate(Artifact artifact) {
        return delegate.locate(artifact);
    }

    @Override
    public ResolvedModuleRevision parse(ResolvedResource mdRef, DependencyDescriptor dd, ResolveData data)
            throws ParseException {
        return delegate.parse(mdRef, dd, data);
    }

    public void publish(Artifact artifact, File src, boolean overwrite) throws IOException {
        delegate.publish(artifact, src, overwrite);
    }

    @Override
    public void reportFailure() {
        delegate.reportFailure();
    }

    @Override
    public void reportFailure(Artifact art) {
        delegate.reportFailure(art);
    }

    @Override
    public void setAllownomd(boolean b) {
        delegate.setAllownomd(b);
    }

    @Override
    public void setCache(String cacheName) {
        delegate.setCache(cacheName);
    }

    @Override
    public void setChangingMatcher(String changingMatcherName) {
        delegate.setChangingMatcher(changingMatcherName);
    }

    @Override
    public void setChangingPattern(String changingPattern) {
        delegate.setChangingPattern(changingPattern);
    }

    @Override
    public void setCheckconsistency(boolean checkConsitency) {
        delegate.setCheckconsistency(checkConsitency);
    }

    @Override
    public void setCheckmodified(boolean check) {
        delegate.setCheckmodified(check);
    }

    @Override
    public void setChecksums(String checksums) {
        delegate.setChecksums(checksums);
    }

    @Override
    public void setDescriptor(String descriptorRule) {
        delegate.setDescriptor(descriptorRule);
    }

    @Override
    public void setEnvDependent(boolean envDependent) {
        delegate.setEnvDependent(envDependent);
    }

    @Override
    public void setEventManager(EventManager eventManager) {
        delegate.setEventManager(eventManager);
    }

    @Override
    public void setForce(boolean force) {
        delegate.setForce(force);
    }

    @Override
    public void setLatest(String strategyName) {
        delegate.setLatest(strategyName);
    }

    @Override
    public void setLatestStrategy(LatestStrategy latestStrategy) {
        delegate.setLatestStrategy(latestStrategy);
    }

    @Override
    public void setName(String name) {
        delegate.setName(name);
    }

    @Override
    public void setNamespace(String namespaceName) {
        delegate.setNamespace(namespaceName);
    }

    @Override
    public void setRepositoryCacheManager(RepositoryCacheManager repositoryCacheManager) {
        delegate.setRepositoryCacheManager(repositoryCacheManager);
    }

    @Override
    public void setSettings(ResolverSettings ivy) {
        delegate.setSettings(ivy);
    }

    @Override
    public void setValidate(boolean validate) {
        delegate.setValidate(validate);
    }

    @Override
    public void setWorkspaceName(String workspaceName) {
        delegate.setWorkspaceName(workspaceName);
    }

    @Override
    public String toString() {
        return delegate.toString();
    }

    @Override
    public void validate() {
        delegate.validate();
    }

}
